<template>
  <div>
    <a-layout id="components-layout-demo-custom-trigger">
      <a-layout-sider v-model="collapsed" :trigger="null" collapsible>
        <div class="logo" />
        <a-menu
          theme="dark"
          mode="horizontal"
          :style="{ lineHeight: '64px' }"
          @click="ClickRouter"
        >
          <!-- 退出登录 -->
          <a-menu-item>
            <!-- 退出登录 -->
            <a-button type="primary" @click="exit">退出登录</a-button>
          </a-menu-item>
        </a-menu>

        <a-menu
          mode="inline"
          :default-selected-keys="['1']"
          :default-open-keys="['sub1']"
          :style="{ height: '100%', borderRight: 0, background: '#334157' }"
          @click="ClickRouter"
        >
          <a-sub-menu key="/main/home/shoplist">
            <span slot="title"><a-icon type="home" />基础管理</span>
            <a-menu-item key="/main/home/shoplist"> 商品管理 </a-menu-item>
            <a-menu-item key="/main/home/shop"> 后台管理</a-menu-item>
          </a-sub-menu>

          <a-sub-menu key="/main/dingdan/jiaoyi">
            <span slot="title"> <a-icon type="laptop" />订单管理 </span>
            <a-menu-item key="/main/dingdan/jiaoyi"> 交易订单 </a-menu-item>
            <a-menu-item key="/main/dingdan/htjy"> 后台交易 </a-menu-item>
          </a-sub-menu>
        </a-menu>
      </a-layout-sider>

      <a-layout>
        <a-layout-header style="background: #fff; padding: 0">
          <a-icon
            class="trigger"
            :type="collapsed ? 'menu-unfold' : 'menu-fold'"
            @click="() => (collapsed = !collapsed)"
          />
        </a-layout-header>

        <a-layout-content
          :style="{
            margin: '24px 16px',
            padding: '24px',
            background: '#fff',
            minHeight: '280px',
          }"
        >
          <router-view />
        </a-layout-content>
      </a-layout>
    </a-layout>
  </div>
</template>

<script>
export default {
  data() {
    return {
      collapsed: false,
    };
  },

  methods: {
    ClickRouter(props) {
      this.$router.push({
        path: props.key,
      });
    },

    // 退出
    exit() {
      localStorage.removeItem("token")
      this.$router.push({
        path:"/login"
      });

      // 在线请求token
      this.$axios.post('http://ceshi5.dishait.cn/admin/logout',{
        token:localStorage.getItem('token') || "",
      }).then(res=>{
        
      })
    },
  },
};
</script>

<style>
</style>